﻿<ItemsControl x:Class="XamlTorrent.DownloadList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ul="clr-namespace:Uniloader.Managers;assembly=UniloaderLib"
    HorizontalAlignment="Stretch" Width="Auto">
    <ItemsControl.Resources>
        <Style x:Key="showSelectionUnfocused" TargetType="ListBoxItem">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Blue"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Blue"/>
            </Style.Resources>
        </Style>
    </ItemsControl.Resources>
    <ItemsControl.ItemTemplate>
        <DataTemplate DataType="{x:Type ul:TransferManager}">
            <Expander Header="{Binding Path=DisplayName, Mode=OneWay}" IsExpanded="True">
                <ListBox ItemsSource="{Binding}" SelectionChanged="ListBox_SelectionChanged" IsSelected="True" SelectionMode="Extended"
                         ItemContainerStyle="{StaticResource showSelectionUnfocused}">
                    <ListBox.ItemTemplate>
                        <DataTemplate DataType="{x:Type ul:TransferTask}">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=DisplayName}" />
                                <ProgressBar Value="{Binding Path=Progress, Mode=OneWay}" Width="100" Maximum="1" Height="16" />
                                <TextBlock Text="{Binding Path=RemainingTime}" Margin="6,0,0,0" />
                                <TextBlock Text="{Binding Path=TaskState}" Margin="6,0,0,0" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Expander>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>
